package com.ln.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.VendorExtension;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/11/18 15:51
 */
@Configuration
public class Swagger2Config {

    @Bean
    public Docket docket(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("ln")
                .apiInfo(getInfo())
                .select()
//                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .apis(RequestHandlerSelectors.basePackage("com.ln.controller"))
                .build()
                ;
        return docket;
    }

    private ApiInfo getInfo(){
        Contact DEFAULT_CONTACT = new Contact("王德法", "http://www.jd.com", "110@qq.com");
        ApiInfo apiInfo = new ApiInfo("在线API", "在线API", "2.0", "http://www.baidu.com",
                DEFAULT_CONTACT, "漫动者", "http://www.taobao.com", new ArrayList<VendorExtension>());
        return apiInfo;
    }
}
